/*-------------------------<-- Start of Description -->-------------------------*\ | PURPOSE: This macro is designed to record the run time of another macro | |--------------------------<-- End of Description -->----------------------------| |--------------------------------------------------------------------------------| |------------------------<-- Start of Files Created -->--------------------------| | SYNTAX: %timenote (macro = _input_dataset_, | | starttime = &starttime); | | Note: In order to function properly, you will have to create a global macro | | variable named starttime before this step; | \-------------------------<-- End of Files Created-->---------------------------*/ %macro timenote /des='Standard Time Note' parmbuff ; %local macro starttime notes daymess hourmess minmess andmess secmess ; %let macro=; %let starttime=; %let syspbuff=%sysfunc(translate(%quote(%substr(%quote(%trim(%quote(%left(%quote(&syspbuff))))), 2, %eval(%length(%trim(%quote(%left(%quote(&syspbuff)))))-2))), %str(%'), %str(%"))); /****/ %let _tnrx_=%sysfunc(rxparse($(1))); %let _xtnpos_=0; %let _xtnlen_=0; %let _xtnoldstr_=; %let _xtntnnewstr_=; %do %while( %sysfunc(rxmatch(&_tnrx_, %quote(&syspbuff))) ); %syscall rxsubstr(_tnrx_, syspbuff, _xtnpos_, _xtnlen_); %let _xtnoldstr_=%quote(%substr(%quote(&syspbuff), &_xtnpos_, &_xtnlen_)); %let _xtntnnewstr_=%quote(%sysfunc(translate(%quote(&_xtnoldstr_), À, %quote(%(), Á, %quote(%)), ´, %quote(,), ®, %quote( )))); %let syspbuff=%sysfunc(tranwrd(%quote(&syspbuff), %quote(&_xtnoldstr_), %quote(&_xtntnnewstr_))); %let _xtnpos_=0; %let _xtnlen_=0; %let _xtnoldstr_=; %let _xtntnnewstr_=; %end; %let _tnnewstr_=&syspbuff; %local _xtnvarcnt_ _xtnvar_; %let _xtnvarcnt_=0; %do %while(%length(%qscan(%nrbquote(&_tnnewstr_), %eval(&_xtnvarcnt_+1), %nrbquote(,)))); %let _xtnvarcnt_=%eval(&_xtnvarcnt_+1); %let _xtnvar_=%nrbquote(%qscan(%nrbquote(&_tnnewstr_), &_xtnvarcnt_, %nrbquote(,))); %let _xtnvar_=%sysfunc(translate(%quote(&_xtnvar_), '(', 'À', ')', 'Á', ',', '´', ' ', '®')); %let _xtnx2_=%trim(%left(%qscan(%quote(&_xtnvar_), 1, %str(=)))); %let _xtnx3_=%substr(%quote(&_xtnvar_), %eval(%index(%quote(&_xtnvar_),%str(=))+1), %eval(%length(&_xtnvar_)-%index(%quote(&_xtnvar_),%str(=)))); %if (not %index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xtnvar_))))), %str(=))) %then %do; %if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xtnx2_))))), %str(%()) eq 1) and (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_xtnx2_))))))), %str(%))) eq 1) %then %let _xtnx3_=%substr(%quote(%trim(%quote(%left(%quote(&_xtnx2_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_xtnx2_)))))-2)); %if (%quote(&_xtnvarcnt_) = %quote(1)) %then %let macro=&_xtnx3_; %else %if (%quote(&_xtnvarcnt_) = %quote(2)) %then %let starttime=&_xtnx3_; %end; %else %if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_xtnx3_))))), %str(%()) eq 1) and (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_xtnx3_))))))), %str(%))) eq 1) and (%index(%nrbquote(upcase(%nrbquote(%sysfunc(compress(%nrbquote(&_xtnx2_)))))), WHERE=) le 1) %then %let &_xtnx2_=%substr(%quote(%trim(%quote(%left(%quote(&_xtnx3_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_xtnx3_)))))-2)); %else %let &_xtnx2_=&_xtnx3_; %end; %*--------------------------------------------------------------* | turn notes off, begin time stamp, globalize and localize all | | variables, calculate key macro variables. | *--------------------------------------------------------------* ; %let notes=%sysfunc(getoption(notes,keyword)) ; %let _tnduration_=%sysevalf(%sysfunc(datetime())-&starttime); %let _tnday_ = %trim(%left(%eval(%sysfunc(day(%sysfunc(datepart(&_tnduration_)))) - 1))); %let _tnhour_ = %trim(%left(%eval(%sysfunc(hour(&_tnduration_))-0))); %let _tnminute_ = %trim(%left(%eval(%sysfunc(minute(&_tnduration_))-0))); %let _tnsecond_ = %trim(%left(%sysevalf(%sysfunc(round(%sysfunc(second (&_tnduration_)), .01))-0))); %let _tndurnote_=; %if (&_tnday_ gt 0) %then %let _tndurnote_= %trim(%left(&_tndurnote_)) %trim(%left(&_tnday_)) days; %if (&_tnhour_ gt 0) %then %let _tndurnote_= %trim(%left(&_tndurnote_)) %trim(%left(&_tnhour_)) hours; %if (&_tnminute_ gt 0) %then %let _tndurnote_= %trim(%left(&_tndurnote_)) %trim(%left(&_tnminute_)) minutes; %if (&_tnsecond_ gt 0) %then %let _tndurnote_= %trim(%left(&_tndurnote_)) %trim(%left(&_tnsecond_)) seconds; options notes ; %put NOTE: The macro %nrbquote(%)%trim(%left(%upcase(¯o))) used &_tndurnote_.. ; options ¬es ; %mend timenote ;